package heip.generator.generer;

import heip.generator.entity.TableClazz;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;


/**
 * 生成service类
 * @author HSWHM
 *
 */
public class ActionGenerator extends AbstractGenerator{
	/**
	 *需要手动修改的变量 
	 */
	//模块名
	private String moduleName = null;
	
	public  ActionGenerator(String moduleName){
		this.moduleName = moduleName;
		gg.put("moduleName",this.moduleName);
		
		if(this.moduleName.indexOf(".")!=-1){
			String path = this.moduleName.replace(".", "/");
			gg.put("modulePath", path);
		}else{
			gg.put("modulePath", this.moduleName);
		}
		
		gg.put("now", new Date());
	}
	
	public void generatorEmpty(TableClazz tableClass,Map<String,Object> params) throws Exception{
		//1.选择相应的模板
		//"基本","树","审核"
	/*	String daoTem= null;
		String serviceTem = null;
		if("树".equals(modelType)){daoTem = treeTem;}
		else if("审核".equals(modelType)){temName = auditTem;}
		else{temName= baseTem;}
		String templatePath = getRealTemPath(temName);
		
	*/	
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("model", tableClass);
		map.putAll(params);
		generator.generateByMap(map, getRealTemPath(emptyTem));
	}
	
	public void generator(TableClazz tableClass,Map<String,Object> params) throws Exception{
		//1.选择相应的模板
		//"基本","树","审核"
	/*	String daoTem= null;
		String serviceTem = null;
		if("树".equals(modelType)){daoTem = treeTem;}
		else if("审核".equals(modelType)){temName = auditTem;}
		else{temName= baseTem;}
		String templatePath = getRealTemPath(temName);
		
	*/	
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("model", tableClass);
		map.putAll(params);
		generator.generateByMap(map, getRealTemPath(baseTem));
	}
	
		
	private String baseTem = "TEMPLATE_1.0/action/base";
	private String emptyTem = "TEMPLATE_1.0/action/empty";
	//private String treeDao = "TEMPLATE_1.0/dao/base";
	//private String baseDao = "TEMPLATE_1.0/dao/base";
	
	//private String baseService ="TEMPLATE_1.0/service/base";
	/*private String baseDao = "TEMPLATE_1.0/dao/base";
	private String baseDao = "TEMPLATE_1.0/dao/base";*/
	
}